#ifndef __GOOGLE_SERVICE_INCLUDE__
#define __GOOGLE_SERVICE_INCLUDE__

#include <string>
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <WinInet.h>

typedef std::string			cstring;
#ifdef _UNICODE
typedef std::wstring		tstring;
#else
typedef std::string			tstring;
#endif

class CGoogleService {
public:
	CGoogleService(LPCTSTR pSource, bool bSSL, LPCTSTR pService);
	~CGoogleService();

	bool Auth(LPCTSTR pEmail, LPCTSTR pPassword);
	bool IsLogined();
	bool HttpGet(LPCTSTR pURL, LPSTR pData, DWORD& dwDataSize, bool bSSL=false);
	bool GetImage(LPCTSTR pURL, LPCTSTR pLocalFile);

private:
	TCHAR m_szSource[30];
	TCHAR m_szService[20];
	TCHAR m_szSID[300];
	TCHAR m_szLSID[300];
	TCHAR m_szAuth[300];
	HINTERNET m_hSession;
	HINTERNET m_hConnect;
	bool m_bSSL;
};

extern bool Utf8ToTCHAR(LPCSTR pUtf8, LPTSTR pStr, DWORD nSize);
extern bool TCHARToUtf8(LPCTSTR pStr, LPSTR pUtf8, DWORD nSize);
extern bool UrlEncode(LPCTSTR pFrom, LPTSTR pTo, DWORD nSize);

#endif
